<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="x-ua-compatible" content="ie=7" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="<%=path%>/css/main.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=path%>/js/include.js"></script>
		<script src="<%=path%>/js/jquery-1.4.4.js" type="text/javascript"></script>
		<script language="javascript">
			var rowIndex=${rowSize};
			function delLine(index){
				var root = document.all("linkList");
				var rows = root.rows;
				//寻找到对应的删除行并进行删除
				for(var pos = 1; pos < rows.length; pos++) {
					var temprow = rows[pos];
					if(temprow.id == index) {
						root.deleteRow(pos);
						break;
					}
				}
				//当删除行操作时更新显示索引
				//当删除行操作时更新显示索引
				for(var pos = 1; pos < rows.length; pos++) {
					var temprow = rows[pos];
					var cells = temprow.cells;
					var cell = cells[0];
					if(typeof(cell) == 'object') {
						cell.innerHTML = pos;
					}
				}	  
			}
		
			function addLine(){
				var linkList = parent.document.all("linkList");
				if(linkList != null) {
			 		var row = linkList.insertRow();
			 		var rows = linkList.rows;
			 		rowIndex++;
					row.id=rowIndex;
					//序号
					var cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = rows.length-1+"<input type='hidden' name='pk_linkman' value=' ' />";
			
					//姓名
					var cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<input type='text' class='input-edit' name='linkman'  />";
					
					//职位
			 		//cell = row.insertCell()
			 		//cell.align = 'center';
			 		//cell.innerHTML = "<input type='text' class='input-edit' name='position' />";
					 	
			 		//性别
			 		//cell = row.insertCell();
			 		//cell.align = 'center';
			 		//cell.innerHTML = getGenderHtml();
			
			 		///电话
			 		cell = row.insertCell()
			 		cell.align = 'center';
			 		cell.innerHTML = "<input type='text'  class='input-edit' name='tel' />";
			 		
			 		//手机
			 		cell = row.insertCell()
			 		cell.align = 'center';
			 		cell.innerHTML = "<input type='text' class='input-edit' name='mobile' />";
			 		
			 		//电子邮箱
			 		cell = row.insertCell()
			 		cell.align = 'center';
			 		cell.innerHTML = "<input type='text' class='input-edit'  name='email' />";
			
			 		//删除
			 		cell = row.insertCell();
			 		cell.align = 'center';
			 		cell.innerHTML = "<a href=\"javascript:delLine('"+rowIndex+"')\" class=\"linkstyle3\">删除</a>";
			 	}
			 	
			}
		 	function getGenderHtml(){
		 		return "<select name='gender' ><option value='1'>男</option><option value='2' >女</option></select>"
		 	}
			
			function checkData(){
				var linkNames=document.getElementsByName("linkman");
				var rows=linkNames.length;
				for(var i=0;i<rows;i++){
					var linkName=linkNames[i].value;
					if(""==linkName){
						alert("联系人姓名不可为空");
						return ;
					}
				}
				form1.submit();
			}
		</script>
	</head>
	<body class="fullbody">
				<div class="context">
					<div class="position">
						<div class="tposi">
							当前位置：
							<a href="javascript:changeMenu(1,'<%=request.getContextPath()%>/infopub/pubmain?menuid=1');" class="linkstyle">首页</a>&nbsp;&gt;&gt;&nbsp;
							<a href="#" class="linkstyle">自助服务</a>&nbsp;&gt;&gt;&nbsp;
							<span class="curposition">联系人维护</span>
						</div>
						<div class="help">
							<a href="javascript:void(null);" onclick="doHelp('<%=request.getContextPath()%>/help/html/LXRWH.html');" class="linkstyle">帮助</a>
						</div>
					</div>
					<div class="margin8"></div>
					<div class="subpage_title">
						<div class="title_index">
							<img src="<%=path%>/images/common/dot03.gif" alt="" border="0" />
							&nbsp;联系人维护
						</div>
					</div>
					<div class="margin20"></div>
					<div class="productlist">
						<div><b>联系人维护</b></div>
						<div class="margin10"></div>
						<div class="spliter_line"></div>
						<div class="margin10"></div>
						<div>
							<form name="form1" action="<%=path%>/selfinfo/saveLinkMan" method="post" >
								<table border="0" cellpadding="0" cellspacing="0" id="linkList"
									class="subpage_table1 withborder2" align="center">
									<tr>
										<th class="w_04">序号</th>
										<th class="w_02">姓名</th>
										<%--<th class="w_02">职位</th>
											<th class="w_01">性别</th>
										--%>
										<th class="w_02">公司固定电话（加区号）</th>
										<th class="w_02">手机</th>
										<th class="w_02">电子邮箱</th>
										<th class="w_04">操作</th>
									</tr>
									<c:if test="${form.infoLinkManVos!=null}">
										<c:forEach items="${form.infoLinkManVos}" var="linkman"
											varStatus="index">
											<tr align="center" id="${index.count}">
												<td width="10%">${index.count}<input type="hidden" name="pk_linkman" value="${linkman.pk_linkman}" /></td>
												<td><input type="text" name="linkman" class='input-edit'   value="${linkman.linkman}" /></td>
												<%--<td><input type="text" name="position" class='input-edit'   value="${linkman.position}" /></td>
												<td>
													<select name="gender" class='input-edit' >
														<option value="1" <c:if test="${linkman.gender!=null&& linkman.gender==1 }">selected</c:if>>男</option>
														<option value="2" <c:if test="${linkman.gender!=null&& linkman.gender==2 }">selected</c:if>>女</option>
													</select>
												</td>
												--%>
												<td><input type="text"  name="tel" class='input-edit'   value="${linkman.tel}"  /></td>
												<td><input type="text"  name="mobile" class='input-edit'    value="${linkman.mobile}" /></td>
												<td><input type="text" name="email" class='input-edit'   value="${linkman.email}" /></td>
												<td class="w_04"> 
													<a href="javascript:delLine('${index.count}')" class="linkstyle3">删除</a>
												</td>
											</tr>
										</c:forEach>
									</c:if>
								</table>
								<table border="0" cellpadding="0" cellspacing="0" 
										class="subpage_table1 withborder2" align="center" width="600">
									<tr>
										<td colspan="9">
											&nbsp;
											<img alt="" src="<%=path%>/images/common/add.png" border="0" />
											&nbsp;
											<a href="javascript:addLine();"
												class="linkstyle3">添加联系人</a>
										</td>
									</tr>
								</table>
								<div class="margin8"></div>
								<div class="buttonrow">
									<input type="button" class="buttonok" value="提交" onclick="checkData();"/>
								</div>
							</form>
						</div>
						<div class="margin20">
							<div id="message" class="msgcolor">
								<c:out value="${ERROR_MESSAGE}"></c:out>
							</div>
						</div>
					</div>
				</div>
			<div class="margin20"></div>
<!--		</div>-->
	</body>
</html>
